home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Online / x3270 / unix_files / Husk.c < prev    next >
Encoding:
C/C++ Source or Header  |  2007-12-08  |  4.1 KB  |  143 lines

  1. /*
  2.  * Copyright 1996, 1999 by Paul Mattes.
  3.  *  Permission to use, copy, modify, and distribute this software and its
  4.  *  documentation for any purpose and without fee is hereby granted,
  5.  *  provided that the above copyright notice appear in all copies and that
  6.  *  both that copyright notice and this permission notice appear in
  7.  *  supporting documentation.
  8.  */
  9.  
  10. /*
  11.  * Husk.c - Husk composite widget
  12.  *    A "Husk" (a nearly useless shell) is a trivial container widget, a
  13.  *    subclass of the Athena Composite widget with a no-op geometry manager
  14.  *    that allows children to move and resize themselves at will.
  15.  */
  16.  
  17. #include "globals.h"
  18. #include <X11/IntrinsicP.h>
  19. #include <X11/StringDefs.h>
  20. #include <X11/Xmu/Misc.h>
  21. #include <X11/Xaw/XawInit.h>
  22. #include "HuskP.h"
  23.  
  24. static void ClassInitialize(void);
  25. static void Initialize(Widget, Widget, ArgList, Cardinal *);
  26. static void Realize(register Widget, Mask *, XSetWindowAttributes *);
  27. static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *);
  28. static XtGeometryResult GeometryManager(Widget, XtWidgetGeometry *,
  29.     XtWidgetGeometry *);
  30. static void ChangeManaged(Widget);
  31. static XtGeometryResult QueryGeometry(Widget, XtWidgetGeometry *,
  32.     XtWidgetGeometry *);
  33.  
  34. HuskClassRec huskClassRec = {
  35.     { /* core_class fields      */
  36.     /* superclass         */ (WidgetClass) & compositeClassRec,
  37.     /* class_name         */ "Husk",
  38.     /* widget_size        */ sizeof(HuskRec),
  39.     /* class_initialize   */ ClassInitialize,
  40.     /* class_part_init    */ NULL,
  41.     /* class_inited       */ FALSE,
  42.     /* initialize         */ Initialize,
  43.     /* initialize_hook    */ NULL,
  44.     /* realize            */ Realize,
  45.     /* actions            */ NULL,
  46.     /* num_actions          */ 0,
  47.     /* resources          */ NULL,
  48.     /* num_resources      */ 0,
  49.     /* xrm_class          */ NULLQUARK,
  50.     /* compress_motion    */ TRUE,
  51.     /* compress_exposure  */ TRUE,
  52.     /* compress_enterleave */ TRUE,
  53.     /* visible_interest   */ FALSE,
  54.     /* destroy            */ NULL,
  55.     /* resize             */ NULL,
  56.     /* expose             */ NULL,
  57.     /* set_values         */ SetValues,
  58.     /* set_values_hook    */ NULL,
  59.     /* set_values_almost  */ XtInheritSetValuesAlmost,
  60.     /* get_values_hook    */ NULL,
  61.     /* accept_focus       */ NULL,
  62.     /* version            */ XtVersion,
  63.     /* callback_private   */ NULL,
  64.     /* tm_table           */ NULL,
  65.     /* query_geometry     */ QueryGeometry,
  66.     /* display_accelerator */ XtInheritDisplayAccelerator,
  67.     /* extension          */ NULL
  68.     }, {
  69.     /* composite_class fields */
  70.     /* geometry_manager   */ GeometryManager,
  71.     /* change_managed     */ ChangeManaged,
  72.     /* insert_child          */ XtInheritInsertChild,
  73.     /* delete_child          */ XtInheritDeleteChild,
  74.     /* extension          */ NULL
  75.     }, {
  76.     /* Husk class fields */
  77.     /* empty          */ 0,
  78.     }
  79. };
  80.  
  81. WidgetClass huskWidgetClass = (WidgetClass)&huskClassRec;
  82.  
  83. static XtGeometryResult 
  84. QueryGeometry(Widget widget unused, XtWidgetGeometry *constraint unused,
  85.     XtWidgetGeometry *preferred unused)
  86. {
  87.     return XtGeometryYes;
  88. }
  89.  
  90. static XtGeometryResult 
  91. GeometryManager(Widget w, XtWidgetGeometry *request,
  92.     XtWidgetGeometry *reply unused)
  93. {
  94.     /* Always succeed. */
  95.     if (!(request->request_mode & XtCWQueryOnly)) {
  96.         if (request->request_mode & CWX)
  97.             w->core.x = request->x;
  98.         if (request->request_mode & CWY)
  99.             w->core.y = request->y;
  100.         if (request->request_mode & CWWidth)
  101.             w->core.width = request->width;
  102.         if (request->request_mode & CWHeight)
  103.             w->core.height = request->height;
  104.         if (request->request_mode & CWBorderWidth)
  105.             w->core.border_width = request->border_width;
  106.     }
  107.     return XtGeometryYes;
  108. }
  109.  
  110. static void 
  111. ChangeManaged(Widget w unused)
  112. {
  113. }
  114.  
  115. static void 
  116. ClassInitialize(void)
  117. {
  118.     XawInitializeWidgetSet();
  119. }
  120.  
  121. static void 
  122. Initialize(Widget request unused, Widget new unused, ArgList args unused,
  123.     Cardinal *num_args unused)
  124. {
  125. }
  126.  
  127. static void 
  128. Realize(register Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
  129. {
  130.     attributes->bit_gravity = NorthWestGravity;
  131.     *valueMask |= CWBitGravity;
  132.  
  133.     XtCreateWindow(w, (unsigned)InputOutput, (Visual *)CopyFromParent,
  134.            *valueMask, attributes);
  135. }
  136.  
  137. static Boolean 
  138. SetValues(Widget current unused, Widget request unused, Widget new unused,
  139.     ArgList args unused, Cardinal *num_args unused)
  140. {
  141.     return False;
  142. }
  143.